#pragma once
#include <vector>
#include <string>

class Tools 
{
public:
    static std::vector<std::string> Split(const std::string& str, char sep = ',')
    {
        std::vector<std::string> array;
        std::string::size_type pos1, pos2;
        pos1 = 0;
        pos2 = str.find(sep);
        while (std::string::npos != pos2)
        {
            array.push_back(str.substr(pos1, pos2 - pos1));
            pos1 = pos2 + 1;
            pos2 = str.find(sep, pos1);
        }

        if (pos1 != str.length())
            array.push_back(str.substr(pos1));

        return array;
    }

    static std::vector<char> ReadFile(const std::string& filepath)
    {
        std::vector<char> buffer;

        std::ifstream infile(filepath, std::ios::binary);
        if (infile.is_open())
        {
            infile.seekg(0, std::ios::end);
            long long fileSize = infile.tellg();
            infile.seekg(0);

            buffer.resize(fileSize);
            infile.read(&buffer[0], fileSize);
            infile.close();
        }
        return buffer;
    }
};